package com.manor.main.custom;

import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
import androidx.annotation.NonNull;

public class AutoDismissDialog extends Dialog {
    //handler 用来更新UI的一套机制也是消息机制
    private final Handler handler = new Handler();

    public AutoDismissDialog(@NonNull Context context) {
        super(context);
    }

    public AutoDismissDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onStart() {
        super.onStart();
        if (handler != null) {
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    dismiss();
                }
            }, 2000);
        }
    }
}
